var args={
    '-h':displayHelp,
    '-r':readFile
}

function displayHelp(){
    console.log('processor:',args)

}

function readFile(file){
    console.log('reading...:',file);
    require('fs').createReadStream(file).pipe(process.stdout);

}

if(process.argv.length>0){
    process.argv.forEach(function (arg,index){
        args[arg].apply(this,process.argv.slice(index+1))
    })
}

// TypeError: Cannot read property 'apply' of undefined
